home *** CD-ROM | disk | FTP | other *** search
- property objectSprite, objectRect, objectPict, mouseIsDown, mouseIn, buttonIsOn, objectHidden, onPict, upPict, downPict, offPict, downNum, downEvent, overEvent, outEvent, sendDownEvent, eventCatcher
-
- on mouseEvent me, xEvent, xLoc
- set lastObjectNum to the number of objectPict
- case xEvent of
- #mouseEnter:
- if mouseIsDown then
- set objectPict to downPict
- else
- set objectPict to upPict
- catchEvent(eventCatcher, overEvent)
- end if
- set mouseIn to 1
- #mouseLeave:
- set objectPict to onPict
- set mouseIn to 0
- #mouseDown:
- set objectPict to downPict
- set mouseIsDown to 1
- #mouseUp:
- if mouseIn then
- set objectPict to upPict
- else
- set objectPict to onPict
- end if
- set mouseIsDown to 0
- #mouseGone:
- set objectPict to onPict
- catchEvent(eventCatcher, outEvent)
- set mouseIsDown to 0
- set mouseIn to 0
- end case
- set thisObjectNum to the number of objectPict
- if lastObjectNum <> thisObjectNum then
- if lastObjectNum = downNum then
- set sendDownEvent to 0
- else
- if thisObjectNum = downNum then
- set sendDownEvent to 1
- end if
- end if
- end if
- if buttonIsOn then
- set the member of sprite objectSprite to objectPict
- updateStage()
- end if
- end
-
- on areYouThere me, xLoc
- if objectHidden then
- return 0
- end if
- if inside(xLoc, objectRect) then
- if sendDownEvent then
- catchEvent(eventCatcher, downEvent)
- end if
- return 1
- end if
- return 0
- end
-
- on turnON me
- if not buttonIsOn then
- set buttonIsOn to 1
- set the member of sprite objectSprite to objectPict
- end if
- end
-
- on turnOff me
- if buttonIsOn then
- set buttonIsOn to 0
- set the member of sprite objectSprite to offPict
- end if
- end
-
- on hide me
- set objectHidden to 1
- set the visible of sprite objectSprite to 0
- end
-
- on reveal me
- set objectHidden to 0
- set the visible of sprite objectSprite to 1
- end
-
- on new me, xSprite
- set objectSprite to xSprite
- set objectRect to the rect of sprite objectSprite
- set buttonIsOn to 0
- set mouseIn to 0
- puppetSprite(objectSprite, 1)
- return me
- end
-
- on setPicts me, pictList
- set onPict to getAt(pictList, 1)
- set upPict to getAt(pictList, 2)
- set downPict to getAt(pictList, 3)
- set offPict to getAt(pictList, 4)
- set objectPict to onPict
- set downNum to the number of downPict
- end
-
- on linkUp me, xCatcher, xDownEvent, xOverEvent, xOutEvent
- set eventCatcher to xCatcher
- set downEvent to xDownEvent
- set overEvent to xOverEvent
- set outEvent to xOutEvent
- end
-
- on subscribe me, xCursor
- subscribe(xCursor, me)
- end
-
- on unsubscribe me, xCursor
- unsubscribe(xCursor, me)
- end
-
- on destroy me
- puppetSprite(objectSprite, 0)
- set me to 0
- end
-